/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agh.air.bpel2bpmn.comparator.impl;

import org.agh.air.bpel2bpmn.comparator.AbstractComparator;
import org.agh.air.bpel2bpmn.exception.PatternNotFoundException;
import org.w3c.dom.Node;

/**
 *
 * @author paletz
 */
public class ExclusiveChoiceComparator extends AbstractComparator {

/*
        <sequence>
            <switch name="Gateway-13078">
                <case condition="">
                    <invoke name="Task-13069" partnerLink="" portType="" operation="" inputVariable="" outputVariable=""/>

                </case>
                <case condition="">
                    <invoke name="Task-13072" partnerLink="" portType="" operation="" inputVariable="" outputVariable=""/>

                </case>
                <case condition="">
                    <invoke name="Task-13075" partnerLink="" portType="" operation="" inputVariable="" outputVariable=""/>

                </case>
            </switch>
        </sequence>
 */
    
    @Override
    public String compare(Node node) throws PatternNotFoundException {
        if (node.getNodeName().equals(SEQUENCE)) {
            if (node.getChildNodes().getLength() == 1 && getFirstChild(node).getNodeName().startsWith(SWITCH)) {
                return node.getFirstChild().getNodeName().replaceFirst(SWITCH, EXCLUSIVE_CHOICE);
            }
        }
        throw new PatternNotFoundException();
    }
}
